$(document).ready(function () {
    $(".submit_person_img").click(function (){
        post_img() ;
    })
});
function post_img() {
    const token = $('input[name=csrfmiddlewaretoken]').val();
    let form_data = new FormData;
    form_data.append("person_img", $("#person_img")[0].files[0]);
    form_data.append("csrfmiddlewaretoken", token) ;
    form_data.append("user", $("span.user").text()) ;
    console.log($("span.user").text()) ;
    $.ajax({
        url: g_upload_img_url,
        method: "POST",
        mimeType: "multipart/form-data",
        contentType: false,        // 告诉jQuery不要去设置Content-Type请求头
        processData: false,        // 告诉jQuery不要去处理发送的数据
        data: form_data,
        success: function(data){
            console.log("上传成功！");
            console.log(data);
            $(".head-img").attr("src", g_static_img_url+data);
            $(".head-img-box").removeClass("img-not-exit") ;
        }, error: function(data){
            console.log("上传失败！");
        }
    })
}